/**
 * Created by zm on 2017/3/3.
 */
import * as types from '../types'

const state = {
  index: 0,
  selectType: 0,
  orderId: '',
  refundId: 0,
  itemId: '',
  mcreateTime: '',
  isRefundTo: false,
  vip: {
    itemId: '',
    payType: '',
    price: '',
    point: ''
  },
  kindId: ''
}

const mutations = {
  [types.USER_ORDER] (state, data) {
    if (undefined !== data.index) {
      state.index = data.index
    }
    if (undefined !== data.selectType) {
      state.selectType = data.selectType
    }
    if (undefined !== data.orderId) {
      state.orderId = data.orderId
    }
    if (undefined !== data.refundId) {
      state.refundId = data.refundId
    }
    if (undefined !== data.itemId) {
      state.itemId = data.itemId
    }
    if (undefined !== data.mcreateTime) {
      state.mcreateTime = data.mcreateTime
    }
    if (undefined !== data.isRefundTo) {
      state.isRefundTo = data.isRefundTo
    }
    if (undefined !== data.kindId) {
      state.kindId = data.kindId
    }
    if (undefined !== data.vip) {
      if (undefined !== data.vip.itemId) {
        state.vip.itemId = data.vip.itemId
      }
      if (undefined !== data.vip.payType) {
        state.vip.payType = data.vip.payType
      }
      if (undefined !== data.vip.price) {
        state.vip.price = data.vip.price
      }
      if (undefined !== data.vip.payType) {
        state.vip.point = data.vip.point
      }
    }
  }
}

export default {
  state,
  mutations
}
